package com.zecan.blog.vo.chattingRecords;

import com.zecan.blog.entity.ChattingRecords;
import lombok.Builder;
import lombok.Data;

import java.util.List;

/**
 * 聊天记录vo
 * @author zecan
 * @Description:
 * @ClassName: ChattringRecordsVo
 * @date 2022/12/20 14:32
 */

@Data
@Builder
public class ChattingRecordsVo {

    // 聊天记录内容
    String message;

    // 当前发布聊天的用户id, 在外层存储的是当前聊天对象的用户id, 在聊天记录list中存储发送内容的用户id
    Integer userId;

    // 头像url
    String avatar;

    // 昵称
    String username;

    // 存储当前聊天窗口内的所有聊天信息
    List<ChattingRecordsVo> recordsVoList;


    public static ChattingRecordsVo chattingRecordsVo(ChattingRecords chattingRecords) {
        return ChattingRecordsVo.builder()
                .userId(chattingRecords.getRecordUserId())
                .message(chattingRecords.getRecordContent())
                .avatar(chattingRecords.getAvatarUrl())
                .username(chattingRecords.getNickname())
                .build();
    }
}
